package com.alan.springBoot.controller;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alan.springBoot.exception.BusinessException;
import com.alan.springBoot.mapper.UserMapper;
import com.alan.springBoot.model.User;

@RestController
@RequestMapping("test2")
public class Test2Controller {

	Logger logger = Logger.getLogger(Test2Controller.class);
	
	@Autowired
	private UserMapper userMapper;
	
	@GetMapping("hello")
	public String hello() {
		String tt ="aa";
		Integer.valueOf(tt);
		try {
			Integer.valueOf(tt);
		} catch (Exception e) {
			throw new BusinessException("TEST",e);
		}
		return "hello";
	}
	
	@RequestMapping("hello1")
	public String hello1() {
		return "hello";
	}
	
	@RequestMapping("user")
	public List<User> user() {
		List<User> list = userMapper.selectByExample(null);
		logger.info("test-user="+list.size());
		return list;
	}
	
}
